//
//  SEGOpenDoorBaseAPI.h
//  YYKitDemo
//
//  Created by 刘山 on 2017/11/10.
//  Copyright © 2017年 Sam. All rights reserved.
//

#import "SEGDoorManagerDelegate.h"
#import "SEGBaseDoorModel.h"
#import "SEGNewMyDoorListModel.h"
#import <ReactiveObjC/ReactiveObjC.h>
#import <CoreBluetooth/CoreBluetooth.h>

#define SEGOpenDoorErrorTipTitleKey @"SEGOpenDoorErrorTipTitleKey"

/**
 门禁类型
 */
typedef NS_ENUM(NSUInteger, SEGDoorType) {
    SEGDoorDeviceType_Common = 1, /*普通门*/
    SEGDoorDeviceType_Bluetooth = 2, /*蓝牙门*/
    SEGDoorDeviceType_QRCode = 3, /*二维码门*/
    SEGDoorDeviceType_RollingGate = 5 /*卷闸门*/
};

/**
 门禁设备类型
 */
typedef NS_ENUM(NSUInteger, SEGDoorDeviceType) {
    SEGDoorDeviceType_Uhome = 1, /*优家园设备*/
    SEGDoorDeviceType_QinLin = 2, /*亲邻科技*/
    SEGDoorDeviceType_Ibeacon = 3, /*ibeacon*/
    SEGDoorDeviceType_DHBLE = 4, /*大豪新蓝牙*/
    SEGDoorDeviceType_IKey = 5, /*招商智锁ikey*/
    SEGDoorDeviceType_HaiKang = 8, /*海康二维码门禁*/
    SEGDoorDeviceType_WeiGuang = 9 /*微光二维码门禁*/
};

// 开门状态
typedef NS_ENUM(NSUInteger, SEGOpenDoorStatus) {
    SEGOpenDoorStatus_Begin = 0, /* 开始开门 (网络门开始请求、二维码门开始请求、蓝牙门判断有权限开始执行)*/
    SEGOpenDoorStatus_Success = 1, /* 开门成功 */
    SEGOpenDoorStatus_Failed = 2, /* 开门失败 */
    SEGOpenDoorStatus_ShowQRCode = 3, /* 显示开门二维码 */
    SEGOpenDoorStatus_ShowRollingGate = 4, /* 显示卷闸门 */
};

// 开门失败的类型
typedef NS_ENUM(NSUInteger, SEGOpenDoorErrorType) {
    SEGOpenDoorErrorType_Unsupport = 0, /*不支持的门禁类型（或门禁model不存在）*/
    SEGOpenDoorErrorType_NoQRDoorAuthority, /* 二维码门禁 没有权限 */
    SEGOpenDoorErrorType_NetworkDoorFail, /* 网络门禁开门失败 */
    SEGOpenDoorErrorType_NoBluetoothAuthority, /* 蓝牙未打开或未授权&不支持 */
    SEGOpenDoorErrorType_OpenBluetoothDoorFail /* 蓝牙门开门失败 */
    
};

//网络门开门错误类型(用于上报开门)
typedef NS_ENUM(NSUInteger, SEGOpenNetworkDoorErroType) {
    SEGOpenNetworkDoorErroType_Normal = 0, /*正常，没错误*/
    SEGOpenNetworkDoorErroType_APPNetworkError = 1, /*客户端网络不稳定*/
    SEGOpenNetworkDoorErroType_ServiceError = 2, /*服务器内部异常*/
    SEGOpenNetworkDoorErroType_HardWareError = 3 /*硬件问题(门禁损坏或流量卡用完)*/
};

typedef void (^SEGOpenDoorManagerCallBack)(SEGOpenDoorStatus status, NSDictionary *dict);

@interface SEGOpenDoorBaseAPI : NSObject <CBPeripheralManagerDelegate>

//@property (nonatomic, weak) id<SEGDoorManagerDelegate> delegate;
@property (nonatomic, strong) SEGNewMyDoorListModel *doorModel;
@property (nonatomic, strong) CBPeripheralManager *peripheralManager;
@property (nonatomic, strong) RACSubject *delegateSubject;

- (void)openDoor;

@end
